﻿<%@ Page Title="factoryinfo" Language="C#" MasterPageFile="~/EasyUI.master" AutoEventWireup="true" CodeBehind="List.aspx.cs" Inherits="jnxc.Web.factoryinfo.List" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"> 

    <script type="text/javascript">
        $(function () {
            InitGird();
            InitSearch();           
        });      
       
        //初始化表格
        function InitGird() {
            $('#tt').datagrid({
                title: '企业列表', //表格标题
                url: 'GetFactory.ashx', //请求数据的页面
                sortName: 'fname', //排序字段
                idField: 'fid', //标识字段,主键
                iconCls: '', //标题左边的图标
                width: '100%', //宽度
                //height: $(parent.document).find("#mainPanle").height() - 35 > 0 ? $(parent.document).find("#mainPanle").height() - 35 : 500, //高度
                nowrap: false, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                sortOrder: 'desc', //排序类型
                remoteSort: true, //定义是否从服务器给数据排序
                fitColumns: true,
                method: 'post',
                columns: [[
                    { field: 'ckb', checkbox: true },
	                { title: '企业名', field: 'fname', width: 150, sortable: true },
                    { title: '地址', field: 'fadd', width: 150 },
                    { title: '电话', field: 'ftel', width: 150 },
                    { title: '联系人', field: 'flinker', width: 150 },
                    { title: '邮箱', field: 'femail', width: 150 },
                    { title: '企业类型', field: 'ftype', width: 150, sortable: true },
                    {
                        title: '状态', field: 'fstate', width: 150, sortable: true, formatter: function (value, row, index) {
                            if(value==0)
                                return '<span style="color:red;">未审核</span>';
                            else
                                return '已审核';

                        }
                    },                    
                    {
                        title: '操作', field: 'pid', width: 80, formatter: function (value, row, index) {
                            return '<a style="color:red" href="javascript:" onclick="$(this).parent().click();showUser();return false;">详细</a>&nbsp;<a style="color:red" href="javascript:" onclick="$(this).parent().click();setUser();return false;">审核</a>';

                        }
                    }
                ]],
                toolbar: "#tab_toolbar",
                queryParams: { "action": "query" },
                pagination: true, //是否开启分页
                pageNumber: 1, //默认索引页
                pageSize: 20, //默认一页数据条数
                rownumbers: true //行号
            });


        }
        //初始化搜索框
        function InitSearch() {
            $("#ipt_search").searchbox({
                width: 200,
                //iconCls: 'icon-save',
                searcher: function (val, name) {
                    $('#tt').datagrid('options').queryParams.search_type = name;
                    $('#tt').datagrid('options').queryParams.search_value = val;
                    $('#tt').datagrid('reload');
                },
                prompt: '请输入查询信息'
            });           
        }       
        function showUser() {

            var row = $('#tt').datagrid('getSelected');
            if (row == null) {
                $.messager.alert("提示", "请选择要显示的行！", "info");
            }
            if (row) {
                $('#dlg').dialog('open').dialog('setTitle', '显示企业');                
                $('#fname').text(row.fname);
                $('#flinker').text(row.flinker);
                $('#fadd').text(row.fadd);
                $('#ftel').text(row.ftel);
                $('#femail').text(row.femail);
                $('#yz').attr("src", row.yz);
                $('#fpic').attr("src", row.fpic);
                $('#zj').attr("src", row.zj);
                $('#sd').attr("src", row.sd);
                var result = $.ajax({
                    url: "GetFactory.ashx?action=getinfo&fid=" + row.fid,
                    type: 'post',
                    dataType: 'json',
                    async: false,
                    cache: false
                }).responseText;
                result = eval('(' + result + ')');
                var psinfo = result[0].psinfo;
                $('#fcontent').html(psinfo);
               
            }
        }
        function setUser() {
            var test = document.getElementById("test").value = "set";
            var row = $('#tt').datagrid('getSelected');
            if (row == null) {
                $.messager.alert("提示", "请选择要审核的行！", "info");
            }
            if (row) {
                $('#fm').form('submit', {
                    url: 'GetFactory.ashx?fid=' + row.fid + "&action=" + test,
                    onSubmit: function () {
                        //return $(this).form('validate');  
                    },
                    success: function (result) {
                        if (result.indexOf("T") == 0) {
                            $('#dlg').dialog('close');
                            $('#tt').datagrid('clearSelections'); //清空选中的行  
                            $.messager.alert("提示", "恭喜您，审核成功！", "info");
                            $('#tt').datagrid('reload');
                        }
                        else {
                            $.messager.alert("提示", "审核失败，请重新操作！", "info");
                            return;
                        }

                    }

                });
            }
        }
       
        function removeUser() {
            var test = document.getElementById("test").value = "delete";
            var row = $('#tt').datagrid('getSelected');
            if (row == null) {
                $.messager.alert("提示", "请选择要删除的行！", "info");
            }
            if (row) {
                $.messager.confirm('提示', '你确定要删除这条信息吗？', function (r) {
                    if (r) {
                        $('#fm').form('submit', {
                            url: 'GetFactory.ashx?fid=' + row.fid + "&action=" + test,
                            onSubmit: function () {
                                //return $(this).form('validate');  
                            },
                            success: function (result) {
                                if (result.indexOf("T") == 0) {
                                    $('#dlg').dialog('close');
                                    $('#tt').datagrid('clearSelections'); //清空选中的行  
                                    $.messager.alert("提示", "恭喜您，信息删除成功！", "info");
                                    $('#tt').datagrid('reload');
                                }
                                else {
                                    $.messager.alert("提示", "删除失败，请重新操作！", "info");
                                    return;
                                }

                            }

                        });
                    }
                })
            }
        }

    </script>
    <style type="text/css">
		.fitem {
			width:210px;
			float:left;
		}
			.fitem label {
				width:120px;
                line-height:22px;
			}
	        .fitem span {
                line-height:22px;
	        }
	</style>
   </asp:Content> 
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table id="tt">
    </table>
    
    <div id="tab_toolbar" style="padding: 4px;">
        <table cellpadding="0" cellspacing="0" style="width: 100%">
            <tr>

                <td style="padding-left: 2px">
                   <a href="#" onclick="removeUser();return false;" id="a_del" class="easyui-linkbutton" iconcls="icon-cancel">删除</a>

                </td>
                <td style="text-align: right; padding-right: 15px">
                    <input id="ipt_search" menu="#search_menu" />
                    <div id="search_menu" style="width: 120px">
                       <div name="usernum">
                            企业名
                        </div>
                        <div name="username">
                            联系人
                        </div>                    
                    </div>
                </td>
            </tr>
        </table>
    </div>   
    <div id="dlg" class="easyui-dialog" style="width: 800px; height:500px; padding: 5px; overflow:auto;"
        data-options="closed:true,buttons:'#dlg-buttons',shadow:false">      
        
        <form id="fm" method="post" >                
                                    
            <div class="fitem">
                <input name="Test" id="test" type="hidden" />     
                <label>企业名称：</label>
                <span id="fname" ></span>
            </div>
            <div class="fitem">                   
                <label>企业地址：</label>
                <span id="fadd" ></span>
            </div>
            <div class="fitem">                   
                <label>电话：</label>
                <span id="ftel" ></span>
            </div>
            <div class="fitem">                   
                <label>联系人：</label>
                <span id="flinker" ></span>
            </div>
            <div class="fitem">                   
                <label>邮箱：</label>
                <span id="femail" ></span>
            </div>
            <div style="clear:both;"></div>
            <div class="fitem" style="width:301px;height:330px;">                   
                <label>企业照片：</label><br />
                <img src="" id="fpic" width="300" height="300"/>
            </div>
            <div class="fitem" style="width:301px;height:330px;">                   
                <label>营业执照：</label>
                <img src="" id="yz" width="300" height="300"/>
            </div>
            <div class="fitem" style="width:301px;height:330px;">                   
                <label>组织机构代码证：</label>
                <img src="" id="zj" width="300" height="300"/>
            </div>
            <div class="fitem" style="width:301px;height:330px;">                   
                <label>税务登记证：</label>
                <img src="" id="sd" width="300" height="300"/>
            </div>
             <div style="clear:both;"></div>
            <div class="fitem">                   
                <label>企业简介：</label><br />
                <div id="fcontent"></div>
            </div>
        </form>
    </div>
    <div id="dlg-buttons">       
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="javascript:$('#dlg').dialog('close')">关闭</a>
    </div>
</asp:Content>
